package com.mybatis03.service;

import com.mybatis03.mapper.DeptMapper;
import com.mybatis03.mapper.EmpMapper;
import com.mybatis03.mapper.InfoMapper;
import com.mybatis03.pojo.Dept;
import com.mybatis03.pojo.Emp;
import com.mybatis03.pojo.Info;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * @author wzm
 * @create 2023-12-06 11:35
 * project_name:web2310
 * @Description
 */
public class service {
    @Autowired
    private DeptMapper deptMapper;
    @Autowired
    private EmpMapper empMapper;

    @Autowired
    private InfoMapper infoMapper;

    //根据id查询部门 同时查询出部门的员工
    public Dept getDeptById(Integer id){
        Dept dept = deptMapper.getDeptById(id);
        List<Emp> empListByDeptId = empMapper.getEmpListByDeptId(dept.getId());
        dept.setEmps(empListByDeptId);
        return dept;
    }

    //查询十个表的信息  都是只是是个表中部分信息
    //定义一个包含了需要十个表中某些字段组成一个实体类
    public Info getInfo(){
        /*InfoMapper.getInfo();*/
       return infoMapper.getInfo();
    }
}
